package com.example.aslongastoday.bean;

import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

/**
 * Bean工厂
 */
public class BeanFactory {
    private static Map<String, Object> beanMap = new HashMap<>();
    private static class Holder{
        private static Gson gson = new Gson();
    }

    public static Gson makeGsonBean(){
        return Holder.gson;
    }

    public static void addBean(String name,Object o){
        beanMap.put(name,o);
    }

    //享元模式
    public static Object getBean(String name){
        return beanMap.get(name);
    }

}
